package com.umeox.zikrringtest.auto_close

import android.widget.TextView
import com.umeox.base.BaseRecyclerViewAdapter
import com.umeox.base.BaseViewHolder
import com.umeox.zikrringtest.R
import com.umeox.zikrringtest.auto_close.deviceManager.DeviceProxy

class DeviceListAdapter : com.umeox.base.BaseRecyclerViewAdapter<DeviceProxy>() {

    private val deviceList = mutableListOf<DeviceProxy>()

    fun refreshData(list: MutableList<DeviceProxy>) {
        deviceList.clear()
        deviceList.addAll(list)
        notifyDataSetChanged()
    }

    override fun getLayoutId(viewType: Int): Int = R.layout.item_device

    override fun getDataByPosition(position: Int): DeviceProxy = deviceList[position]

    override fun getTotalSize(): Int = deviceList.size

    override fun convert(holder: com.umeox.base.BaseViewHolder, data: DeviceProxy, position: Int) {
        holder.getView<TextView>(R.id.item_name).text = data.device.name
        holder.getView<TextView>(R.id.item_mac).text = data.device.mac
    }

}